<template>
  <div class="book-container">
    <el-row :gutter="20" style="width: 1200px; margin: 0 auto;">
      <el-col :span="6" v-for="(item, index) in bookData" :key="index" style="text-align: center; margin-bottom: 20px;">
        <el-card :body-style="{ padding: '0px'}" style="width: 200px; display: inline-block">
          <img :src="imgPath(item.cover)" style="width: 200px; height: 266.66px;">
          <div style="padding: 14px;">
            <el-tooltip class="item" effect="dark" :content="item.title" placement="top" popper-class="tip">
              <h4 class="name">{{item.title}}</h4>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" :content="`${item.author} | ${item.majorCate}`" placement="top" popper-class="tip">
              <p class="author">
                {{item.author}} | {{item.majorCate}}
              </p>
            </el-tooltip>
            <el-tooltip class="item" effect="dark" :content="item.shortIntro" placement="top" popper-class="tip">
              <p class="introduce">{{item.shortIntro}}</p>
            </el-tooltip>
            <div class="bottom clearfix">
              <el-button type="primary" @click="readClick(item._id)">开始阅读</el-button>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  props: {
    bookData: {
      type: Array,
      required: true
    }
  },
  methods: {
    imgPath (cover) {
      return 'http://statics.zhuishushenqi.com' + cover
    },
    readClick (id) {
      this.$router.push({
        path: '/bookDetail',
        query: {
          id: id
        }
      })
    }
  }
}
</script>

<style lang="scss">
.book-container {
  .el-card__body {
    border: 1px solid #f5d3c6;
    -moz-box-shadow:8px 2px 5px #333333, 2px 2px 5px #333333; -webkit-box-shadow:8px 2px 5px #333333, 2px 2px 5px #333333; box-shadow:8px 2px 5px #333333, 2px 2px 5px #333333;
  }
  .name {
    height: 22px;
    line-height: 22px;
    color: #333!important;
    font-weight: bold;
  }
  .author {
    height: 28px;
    line-height: 28px;
    color: #999;
    text-overflow: ellipsis;
    overflow: hidden;
    font-size: 12px;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
  }
  .introduce {
    height: 40px;
    margin: 5px 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    line-height: 20px;
    color: #999;
    text-overflow: ellipsis;
    overflow: hidden;
    font-size: 12px;
  }
}
.tip {
  max-width: 300px!important;
}
</style>
